﻿using System.Collections;
using UnityEngine;


public class UIManager : MonoBehaviour
{
       
    public static UIManager Instance;
    private void Awake()
    {if (Instance != null && Instance != this)
    {
        Destroy(gameObject);
        return;
    }
    Instance = this;
    DontDestroyOnLoad(gameObject);
    }

    [SerializeField] private GameObject _startUI;
    [SerializeField] private GameObject _resetUI;
    [SerializeField] private GameObject _gameplayUI;
    [SerializeField] private GameObject _failureUI;
    [SerializeField] private GameObject _endUI;

    private GameObject _currentUI;

    public GameObject Show(GameState state) 
    {
        if (_currentUI != null) { _currentUI.SetActive(false); }
            
        switch (state)
        {
            case GameState.Start:
                _currentUI = _startUI;
                break;
            case GameState.Reset:
                _currentUI = _resetUI;
                break;
            case GameState.Running:
                _currentUI= _gameplayUI;
                break;
            case GameState.Failure:
                _currentUI = _failureUI;
                break;
            case GameState.End:
                _currentUI = _endUI;
                break;
            default:
                break;
        }
        _currentUI.SetActive(true);
        return _currentUI;
    }
}
